﻿using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Newtonsoft.Json;

namespace Aesha.WoW.Broker.Model
{
    public class AuctionListing
    {
        public long AuctionId { get; set; }
        [JsonProperty("Item")]
        public int ItemId { get; set; }
        public string Owner { get; set; }
        public long Bid { get; set; }
        public long BuyOut { get; set; }
        public int Quantity { get; set; }
        public string TimeLeft { get; set; }
        public DateTime FirstSeen { get; set; }
        public Nullable<DateTime> LastUpdated { get; set; }
        public bool Sold { get; set; }

        public static EntityTypeConfiguration<AuctionListing> Mapping()
        {
            var m = new EntityTypeConfiguration<AuctionListing>();

            m.HasKey(t => t.AuctionId);

            m.Property(t => t.Owner).HasMaxLength(50).IsUnicode(false);
            m.Property(t => t.TimeLeft).HasMaxLength(10).IsUnicode(false);

            m.Property(t => t.AuctionId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            return m;
        }

    }

    
}
